﻿using Bentley.CifNET.GeometryModel.SDK;
using Bentley.CifNET.LinearGeometry;
using BCL = Bentley.CifNET.GeometryModel.SDK;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CheccCoverplateCulvertAssemble.Common;
using CheccCoverplateCulvertAssemble.Tools;
using CheccCoverplateCulvertAssemble.run;

namespace CheccCoverplateCulvertAssemble.commons
{
    internal class AligmentHomologousProperties
    {
        /// <summary>
        /// 获取路线详情
        /// </summary>
        /// <param name="alignment"></param>
        /// <returns></returns>
        public static AlignmentProperty GetAlignmentProperties(Alignment alignment)
        {
            AlignmentProperty alignmentProperty = new AlignmentProperty();
            string startStation = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "起点桩号");
            string endStation = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "终点桩号");
            string highwayClassification = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "公路等级");
            string GLSS = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "设计时速(km/h)");
            string baseWidth = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "路基宽度(米)");
            string antiKnock = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "抗震烈度");
            string autoLoad = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "汽车荷载");
            string environmentType = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "环境类别");
            string numberPrefix = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "桩号前缀");
            string slope = ElementProperty.GetElePropertyValue(alignment.DgnECInstance.Element, "路拱横坡(%)");
            if (string.IsNullOrEmpty(slope)) Commands.isBimCenter = true;
            else Commands.isBimCenter = false;
            //获取路线上的桩号系统
            BCL.Stationing station = alignment.Stationing;
            //平面线
            Bentley.CifNET.LinearGeometry.LinearElement LE = alignment.LinearGeometry;

            alignmentProperty.StaStation = Convert.ToDouble(startStation);
            alignmentProperty.EndStation = Convert.ToDouble(endStation);
            alignmentProperty.HighwayLevel = highwayClassification;
            alignmentProperty.DesignSpeed = GLSS;
            alignmentProperty.WidthOfSubgrade = baseWidth;
            alignmentProperty.AntiKnock = antiKnock;
            alignmentProperty.AutoLoad = autoLoad;
            alignmentProperty.EnvironmentType = environmentType;
            alignmentProperty.StationPrefix = numberPrefix;
            alignmentProperty.Station = station;
            alignmentProperty.Linear = LE;
            alignmentProperty.ThisAlignment = alignment;

            return alignmentProperty;
        }
    }
}
